<?php
namespace addons\yalimedia\service;

use app\admin\model\yalimedia\Uservip;
use think\Db;

class User
{

    public $model;


    public static function isVip($user_id){

//        $userVipModel = new Uservip();
//        $userVip = $userVipModel->where(['user_id'=>$user_id])->find();
//        if($userVip){
//            if($userVip['expiretime'] === 0){
//               return 1;
//            }else{
//                if($userVip['expiretime']>time()){
//                    return 1;
//                }else{
//                    return 0;
//                }
//            }
//        }else{
//            return 0;
//        }
        $auth = \app\common\library\Auth::instance();
        $auth->setAllowFields(['id', 'username', 'nickname', 'mobile', 'avatar', 'score', 'birthday', 'money', 'group', 'group_id', 'verification', 'child_user_count', 'child_user_count_1', 'child_user_count_2', 'total_consume','grade','grade_time','number']);
        $data = $auth->getUserinfo();

        if ($data['grade'] == 1 || $data['grade'] == 2) {
            return 1;
        }

        return 0;
    }

}